﻿using System.Collections.Generic;
//
using PerceptiveMCAPI.Types;
//
namespace PerceptiveMCAPI
{
	internal static partial class ValidateInput
	{
		#region ================================================================== IsOK & Validate Base

		// check for errors
		internal static bool IsOK( List<Api_ValidatorMessage> messages )
		{
			foreach ( Api_ValidatorMessage message in messages )
			{
				if ( message.MessageLevel >= EnumValues.MessageLevel.Error )
				{ return false; }
			}
			return true;
		}

		// base input 
		internal static List<Api_ValidatorMessage> ValidateBaseParameters( Api_BaseInput input )
		{
			List<Api_ValidatorMessage> MessageList = new List<Api_ValidatorMessage>();
			// ------------------------------------------------------------------------------------- NO validation for JSON input
			if ( input.api_AccessType == EnumValues.AccessType.JSON )
			{
				MessageList.Add( Validator.FormatMsg( EnumValues.MessageLevel.Warning, "API Validate",
					string.Format( "API Validation not supported for JSON string input: '{0}'.", "API Validate" ) ) );
			}
			// -------------------------------------------------------------------------
			// make sure info is set //
			if ( input.api_AccessType == EnumValues.AccessType.NotSpecified )
			{
				MessageList.Add( Validator.FormatMsg( EnumValues.MessageLevel.Error, "API Access Type",
					string.Format( "API parameter not set: '{0}'.", "API Access Type" ) ) );
			}
			if (
				input.api_OutputType == EnumValues.OutputType.NotSpecified )
			{
				MessageList.Add( Validator.FormatMsg( EnumValues.MessageLevel.Error, "API Output Type",
				  string.Format( "API parameter not set: '{0}'.", "API Output Type" ) ) );
			}
			if ( string.IsNullOrEmpty( input.api_Method ) )
			{
				MessageList.Add( Validator.FormatMsg( EnumValues.MessageLevel.Error, "API Method Name",
				string.Format( "API parameter not set: '{0}'.", "API Method Name" ) ) );
			}
			// ------------------
			return MessageList;
		}

		#endregion
	}
}
